define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'activityone/activitycheckin/index' + location.search,
                    // add_url: 'activityone/activitycheckin/add',
                    // edit_url: 'activityone/activitycheckin/edit',
                    del_url: 'activityone/activitycheckin/del',
                    multi_url: 'activityone/activitycheckin/multi',
                    import_url: 'activityone/activitycheckin/import',
                    table: 'event_checkin',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'coupon_text', title: __('Giftcoupon'),operate: false},
                        {field: 'minCount', title: __('Mincount')},
                        // {field: 'status', title: __('Status'), searchList: {"10":__('Status 10')}, formatter: Table.api.formatter.status},
                       // {field: 'event_id', title: __('Event_id')},
                        {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'start_time', title: __('Start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'created_at', title: __('Created_at')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
                        buttons: [
                            // {
                            //     name: 'detail',
                            //     text: __('添加获胜队伍'),
                            //     title: __('添加获胜队伍'),
                            //     classname: 'btn btn-xs btn-primary btn-dialog',
                            //     icon: 'fa fa-list',
                            //     url: 'activity/activitylist/detail',
                            //     visible: function (row) {
                            //         if(row.status == 0) {
                            //             return true;
                            //         }
                            //         return false
                            //     }
                            // },
                            // {
                            //     name: 'detail',
                            //     text: __('添加队伍'),
                            //     title: __('添加队伍'),
                            //     classname: 'btn btn-xs btn-primary btn-dialog',
                            //     icon: 'fa fa-list',
                            //     url: 'activity/rankslist/add',
                            // },
                            {
                                name: 'detail',
                                text: __('查看打卡用户'),
                                title: __('查看打卡用户'),
                                classname: 'btn btn-xs btn-primary btn-dialog',
                                icon: 'fa fa-list',
                                extend: 'data-area=["99%","99%"]',
                                url: 'activityone/useronlist?ids={ids}',
                
                            },
                
                        ],
                    }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
